package com.lucenly.card.adapter;

import android.graphics.Color;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lucenly.card.R;
import com.lucenly.card.bean.RankBean;
import com.lucenly.card.utils.GlideUtils;
import com.lucenly.card.view.MultiImageView;

import java.util.List;

public class InvitationAAdapter extends BaseMultiItemQuickAdapter<RankBean,BaseViewHolder> {


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public InvitationAAdapter(List<RankBean> data) {
        super(data);
        addItemType(0,R.layout.item_invitation_a);
        addItemType(1,R.layout.item_invitation_a_2);
    }


    @Override
    protected void convert(BaseViewHolder helper, RankBean item) {
        int itemViewType = helper.getItemViewType();
        if(itemViewType==0){
            MultiImageView iv_img = helper.getView(R.id.iv_img);
            TextView tv_num = helper.getView(R.id.tv_num);
            ImageView iv_hg = helper.getView(R.id.iv_hg);
            TextView tv_name = helper.getView(R.id.tv_name);
            TextView tv_num1 = helper.getView(R.id.tv_num1);
            TextView tv_money = helper.getView(R.id.tv_money);
            GlideUtils.getInstance(mContext).load(mContext,item.avatar,iv_img,R.color.gray_de);
            tv_name.setText(item.nickname);
            tv_money.setText(item.rewardFee+"");
            tv_num1.setText(item.num+"个");
            tv_num.setText(item.rank+"");
            if(item.rank==1){
                iv_hg.setImageResource(R.mipmap.no1_huangguan2x);
                tv_num.setBackgroundResource(R.mipmap.no1_bg2x);
                iv_img.setBorderColor(Color.parseColor("#facf0c"));
                tv_num.setText("No."+item.rank);
            }else if(item.rank==2){
                iv_hg.setImageResource(R.mipmap.no2_huangguan2x);
                tv_num.setBackgroundResource(R.mipmap.no2_bg2x);
                iv_img.setBorderColor(Color.parseColor("#8eaeff"));
                tv_num.setText("No."+item.rank);
            }else if(item.rank==3){
                iv_hg.setImageResource(R.mipmap.no3_huangguan2x);
                tv_num.setBackgroundResource(R.mipmap.no3_bg2x);
                iv_img.setBorderColor(Color.parseColor("#ff8c7f"));
                tv_num.setText("No."+item.rank);
            }
        }else{
            MultiImageView iv_img = helper.getView(R.id.iv_img);
            TextView tv_num = helper.getView(R.id.tv_num);
            TextView tv_name = helper.getView(R.id.tv_name);
            TextView tv_num1 = helper.getView(R.id.tv_num1);
            TextView tv_money = helper.getView(R.id.tv_money);
            GlideUtils.getInstance(mContext).load(mContext,item.avatar,iv_img,R.color.gray_de);
            tv_name.setText(item.nickname);
            tv_money.setText(item.rewardFee+"");
            tv_num1.setText(item.num+"个");
            tv_num.setText(item.rank+"");
        }
    }
}
